<?php 
/**
 * Class description
 *
 * @since 30 мая 2010
 * @author diotheos
 */
class Zend_View_Helper_FormRange extends Zend_View_Helper_FormElement {
	protected $_html = '';
	private $_parameters = array(
	   'elements' => array(
		   'from'  => array(
	           'type' => 'text',
	           'label'=> array(
	               'text' => 'От'
	           ),
	           'options' => array()
	       ),
	       'to' => array(
	           'type' => 'select',
	           'label'=> array(
	               'text' => 'До'
	           ),
	           'options' => array()
	       )
	   )	   
	);
	/**
	 * Function description
	 *
	 * @since 30 мая 2010
	 * @author diotheos
	 */
	public function formRange($name, $value = null, $attribs = null) {
//        if(null === $attribs){
        	$attribs = $this->_parameters;
//        }
		$this->_html = "<div class='form-section'>";
        foreach($attribs['elements'] as $elName=>$elParams){
        	$classNameSuffixed = "Zend_View_Helper_Form".ucfirst($elParams['type']);
        	$classMainFunction = 'form'.ucfirst($elParams['type']);
        	$$elName = new $classNameSuffixed();
        	$$elName->setView($this->view);
        	$this->_html .= $$elName->$classMainFunction($name. "[$elName]",'',$elParams['options']);
        }
        
        
//        $first->setView($this->view);
        
//        $areanum = $geonum = $localnum = '';
//        if ($value)
//            list($areanum, $geonum , $localnum) = split('-',$value);
//
//        $helper = new Zend_View_Helper_FormText();
//        $helper->setView($this->view);
//        
//
//        $this->_html .= $helper->formText($name . '[areanum]',$areanum,array('size'=>3,'maxlength'=>3));
//        $this->_html .= $helper->formText($name . '[geonum]',$geonum,array('size'=>3,'maxlength'=>3));
//        $this->_html .= $helper->formText($name . '[localnum]',$localnum,array('size'=>4,'maxlength'=>4));
        $this->_html .= "</div>";
        return $this->_html;
    }
}